package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ScreeningSchedule;
import com.ruoyi.system.service.IScreeningScheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 放映计划信息数据Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/system/schedule")
public class ScreeningScheduleController extends BaseController
{
    @Autowired
    private IScreeningScheduleService screeningScheduleService;

    /**
     * 查询放映计划信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScreeningSchedule screeningSchedule)
    {
        startPage();
        List<ScreeningSchedule> list = screeningScheduleService.selectScreeningScheduleList(screeningSchedule);
        return getDataTable(list);
    }

    /**
     * 导出放映计划信息数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:export')")
    @Log(title = "放映计划信息数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScreeningSchedule screeningSchedule)
    {
        List<ScreeningSchedule> list = screeningScheduleService.selectScreeningScheduleList(screeningSchedule);
        ExcelUtil<ScreeningSchedule> util = new ExcelUtil<ScreeningSchedule>(ScreeningSchedule.class);
        util.exportExcel(response, list, "放映计划信息数据数据");
    }

    /**
     * 获取放映计划信息数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:query')")
    @GetMapping(value = "/{screeningId}")
    public AjaxResult getInfo(@PathVariable("screeningId") Long screeningId)
    {
        return success(screeningScheduleService.selectScreeningScheduleByScreeningId(screeningId));
    }

    /**
     * 新增放映计划信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:add')")
    @Log(title = "放映计划信息数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScreeningSchedule screeningSchedule)
    {
        return toAjax(screeningScheduleService.insertScreeningSchedule(screeningSchedule));
    }

    /**
     * 修改放映计划信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:edit')")
    @Log(title = "放映计划信息数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScreeningSchedule screeningSchedule)
    {
        return toAjax(screeningScheduleService.updateScreeningSchedule(screeningSchedule));
    }

    /**
     * 删除放映计划信息数据
     */
    @PreAuthorize("@ss.hasPermi('system:schedule:remove')")
    @Log(title = "放映计划信息数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{screeningIds}")
    public AjaxResult remove(@PathVariable Long[] screeningIds)
    {
        return toAjax(screeningScheduleService.deleteScreeningScheduleByScreeningIds(screeningIds));
    }
}
